import path from "path";
import { program } from "commander";
import { MsgBuilder } from "./MsgBuilder";

program.requiredOption("-i <协议消息目录>", "协议消息目录")
    .requiredOption("-o <代码导出目录>", "代码导出目录")
    .option("-cfg", "是否导出路由配置")
    .parse(process.argv);

let { i: inputDir, o: outputDir, Cfg: outMsgCfg } = program.opts();

inputDir = path.resolve(inputDir);
outputDir = path.resolve(outputDir);
console.log(`[协议消息目录]：${inputDir}`);
console.log(`[代码导出目录]：${outputDir}`);
console.log("=== 开始构建协议消息 ===");
console.log("........................");
new MsgBuilder(inputDir, outputDir, outMsgCfg).build();
console.log("........................");
console.log("=== 构建完成 ===");